//
//  StarView.m
//  WXmovie1
//
//  Created by HZApple on 16/3/30.
//  Copyright © 2016年 hdu. All rights reserved.
//

#import "StarView.h"

@implementation StarView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (void)awakeFromNib
{
    [super awakeFromNib];
    [self createSubview];
    self.backgroundColor = [UIColor clearColor];
    
}

- (void)createSubview {
    
    _grayStarView = [[UIView alloc] init];
    _yellowStarView = [[UIView alloc] init];
    
    [self addSubview:_grayStarView];
    [self addSubview:_yellowStarView];
    
    UIImage *image = [UIImage imageNamed:@"gray"];
    
    float scale = self.height / (image.size.height + 0.8);
    
    _grayStarView.transform = CGAffineTransformMakeScale(scale, scale);
    _yellowStarView.transform = CGAffineTransformMakeScale(scale, scale);
    
    
    _grayStarView.backgroundColor = [UIColor colorWithPatternImage:image];
   
    _yellowStarView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"yellow"]];
    
    _grayStarView.frame = CGRectMake(0, 0, 5 * self.height, self.height);
    
    
}

- (void)changeYellowStarFrameWithRating:(float)rating {
    
    _yellowStarView.frame = CGRectMake(0, 0, 5 * self.height *rating / 10, self.height);
}


@end
